package com.justnow.offer;

/**
 * @author justnow
 * Created on 2020-10-14
 * Description
 */
public class Xinhuasan02 {
    public long power (String input) {
        if (input == null || input.length() <= 0) {
            return -1;
        }

        String[] array = input.split(" ");

        for (int i = 0; i < array.length; i++) {
            if (Integer.valueOf(array[i]) < 1 || Integer.valueOf(array[i]) > 10) {
                return -1;
            }
        }

        long sum = 0;

        for (int i = 0; i < array.length - 1; i++) {

            sum += Math.pow(Integer.valueOf(array[i]), Integer.valueOf(array[i + 1]));
        }
        return sum;
    }

    public static void main(String[] args) {
        Xinhuasan02 xinhuasan02 = new Xinhuasan02();
        long power = xinhuasan02.power("10 10 10 10 10 10 10");
        System.out.println(power);
    }

}
